//
//  AddStarView.m
//  LiveStar
//
//  Created by 漪珊 on 2017/6/1.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "AddStarView.h"
#import "RechargeListModel.h"
@interface AddStarView(){
    NSArray *_addNumsArray;
    NSArray *_addMoneyArray;
    NSArray *_addBtnArray;
}
@end
@implementation AddStarView

- (void)awakeFromNib {
    [super awakeFromNib];
    _addNumsArray = @[self.firstNumLabel,self.secondNumLabel,self.thirdNumLabel,self.fourthNumLabel];
    _addMoneyArray = @[self.firstMoneyLabel,self.secondMoneyLabel,self.thirdMoneyLabel,self.fourthMoneyLabel];
    _addBtnArray = @[self.firstBtn,self.secondBtn,self.thirdBtn,self.fourtBtn];
    kViewRadius(self.backView, 10);
    kButtonRadius(self.buyBtn, 6);
    [self selectedType:self.firstBtn];
}


//充值
- (IBAction)Recharge:(id)sender {
    
}

//兑换
- (IBAction)exchangeAction:(id)sender {
    [self.delegate exchangeNums];
}


//关闭兑换框
- (IBAction)tipClose:(id)sender {
    [self.delegate closeAddStarTipView];
}

//选中
- (IBAction)selectedType:(id)sender {
    int tag;
    if (sender == self.firstBtn) {
        tag = 0;
    } else if (sender == self.secondBtn) {
        tag = 1;
    } else if (sender == self.thirdBtn) {
        tag = 2;
    } else {
        tag = 3;
    }
    for (UIButton *btn in _addBtnArray) {
        if (btn == sender) {
            [sender setImage:kSET_IMAGE(@"addStar_selected") forState:UIControlStateNormal];
        } else {
            [btn setImage:kSET_IMAGE(@"addStar_normal") forState:UIControlStateNormal];
        }
    }
    for (UILabel *label in _addNumsArray) {
        if (label == _addNumsArray[tag]) {
            label.textColor = HESHEX_COLOR(@"ff9900");
        } else {
            label.textColor = HESHEX_COLOR(@"333333");
        }
    }
    for (UILabel *label in _addMoneyArray) {
        if (label == _addMoneyArray[tag]) {
            label.textColor = HESHEX_COLOR(@"ffcc99");
        } else {
            label.textColor = HESHEX_COLOR(@"666666");
        }
    }
    [self.delegate selectedTypeWithTag:tag];
}

- (void)setDataArray:(NSArray *)dataArray {
    _dataArray = dataArray;
    for (int i = 0; i<_addNumsArray.count; i++) {
        RechargeListModel *model = _dataArray[i];
        UILabel *label = _addNumsArray[i];
        UILabel *label1 = _addMoneyArray[i];
        label.text = model.c_name;
        label1.text = KString(model.c_value);
    }
}
@end
